<?php
define("dbhost", "localhost");
define("dbuser", "root");
define("dbpass", "123123");
define("dbname", "test");
class getdata{
	public $myconn;

	function __construct(){
		$this->myconn = new mysqli(dbhost, dbuser, dbpass, dbname);
		if(!$this->myconn){
			die("数据库连接失败！".$this->myconn->connect_error);
		}
		$this->myconn->query("set names utf8");
	}
	function SelectSql($sql){
		$result = $this->myconn->query($sql);
		$reslist = array();
		if ($result->num_rows > 0) {
			while($row = $result->fetch_assoc()){
				$reslist[] = $row;
			}   
		}
		return json_encode($reslist);
	}

	function ExecSql($sql){
		return $this->myconn->query($sql) or die("数据操作失败</br>".$sql."</br>".$this->myconn->error);
	}	
}
?>